import { useAxios } from '@/hooks/web/useAxios'

const request = useAxios()

export const loginApi = (data) => {
  // return request.post({
  //   url: '/user/login',
  //   data
  // })
  return new Promise((resolve) => {
    resolve({
      data: {
        password: 'admin',
        username: 'admin',
        roleId: '1',
        role: 'admin'
      },
      code: '0000'
    })
  })
}

export const loginOutApi = () => {
  // return request.get({ url: '/user/loginOut' })
  return new Promise((resolve) => {
    resolve({ code: '0000', data: null })
  })
}

export const getUserListApi = ({ params }) => {
  return request.get({ url: '/user/list', params })
}

export const getAdminRoleApi = ({ params }) => {
  // return request.get({ url: '/role/list', params })
  return new Promise((resolve) => {
    resolve({
      "code": "0000",
      "data": {
        "list": [
          {
            "path": "/level",
            "component": "#",
            "redirect": "/level/menu1/menu1-1/menu1-1-1",
            "name": "Level",
            "meta": {
              "title": "router.level",
              "icon": "carbon:skill-level-advanced"
            },
            "children": [
              {
                "path": "menu1",
                "name": "Menu1",
                "component": "##",
                "redirect": "/level/menu1/menu1-1/menu1-1-1",
                "meta": {
                  "title": "router.menu1"
                },
                "children": [
                  {
                    "path": "menu1-1",
                    "name": "Menu11",
                    "component": "##",
                    "redirect": "/level/menu1/menu1-1/menu1-1-1",
                    "meta": {
                      "title": "router.menu11",
                      "alwaysShow": true
                    },
                    "children": [
                      {
                        "path": "menu1-1-1",
                        "name": "Menu111",
                        "component": "views/Level/Menu111",
                        "meta": {
                          "title": "router.menu111"
                        }
                      }
                    ]
                  },
                  {
                    "path": "menu1-2",
                    "name": "Menu12",
                    "component": "views/Level/Menu12",
                    "meta": {
                      "title": "router.menu12"
                    }
                  }
                ]
              },
              {
                "path": "menu2",
                "name": "Menu2Demo",
                "component": "views/Level/Menu2",
                "meta": {
                  "title": "router.menu2"
                }
              }
            ]
          }
        ]
      }
    })
  })
}

export const getTestRoleApi = ({ params }) => {
  return request.get({ url: '/role/list', params })
}
